home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
comm
/
mail
/
Mutt089src.lha
/
Mutt-0.89i-AMIGA
/
src
/
getdomain.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-01-28
|
927b
|
56 lines
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "mutt.h"
#include "protos.h"
#ifndef STDC_HEADERS
int fclose ();
#endif
/* poor man's version of getdomainname() for systems where it does not return
* return the DNS domain, but the NIS domain.
*/
int getdnsdomainname (char *s, size_t l)
{
FILE *f;
char tmp[1024];
char *p = NULL;
if ((f = fopen ("/etc/resolv.conf", "r")) == NULL) return (-1);
tmp[sizeof (tmp) - 1] = 0;
l--; /* save room for the terminal \0 */
while (fgets (tmp, sizeof (tmp) - 1, f) != NULL)
{
p = tmp;
while (ISSPACE (*p)) p++;
if (strncmp ("domain", p, 6) == 0 || strncmp ("search", p, 6) == 0)
{
p += 6;
while (ISSPACE (*p)) p++;
if (*p)
{
while (*p && !ISSPACE (*p) && l > 0)
{
*s++ = *p++;
l--;
}
if (*(s-1) == '.') s--;
*s = 0;
fclose (f);
return (0);
}
}
}
fclose (f);
return (-1);
}